<?php
    header('Access-Control-Allow-Origin: *');
    header('Content-Type:text/html;charset=utf-8');
    $con = mysqli_connect("localhost","root","root","mydb");
    $status = $_GET['status'];
    $classId = $_GET['classId'];
    if($status == 'student'){
        $uId = $_GET['uid'];
        $sql1 = "DELETE FROM lesson_sign WHERE s_id = '$uId' AND l_id = '$classId';";
        $res1 = mysqli_query($con,$sql1);
        $sql = "DELETE FROM lessonstu WHERE s_id = '$uId' AND l_id = '$classId';";
        $res = mysqli_query($con,$sql);
    }else if($status == 'teacher'){
        $sql1 = "DELETE FROM lesson_sign WHERE l_id = '$classId';";
        $res1 = mysqli_query($con,$sql1);
        $sql = "DELETE FROM lesson where l_id = '$classId';";
        $res = mysqli_query($con,$sql);
    }
    if(mysqli_affected_rows($con) > 0){
        echo 'ok';
    }else{
        echo 'fail';
    }
    mysqli_close($con);
?>